using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

using Pervote.Core;
using Pervote.Core.Logic;

public partial class Search : RegularPageBase
{
    private List<Poll> randomPolls;
    public List<Poll> RandomPolls
    {
        get { return randomPolls; }
        set { randomPolls = value; }
    }

    private string searchKey;
    public string SearchKey
    {
        get { return searchKey; }
        set { searchKey = value; }
    }

    new protected void Page_Load(object sender, EventArgs e)
    {
        string searchKey = Request["searchTextBox"];
        if (String.IsNullOrEmpty(searchKey))
        {
            string redirectUrl = (Request.UrlReferrer != null) ? Request.UrlReferrer.AbsoluteUri : "/";
            Response.Redirect(redirectUrl);
        }

        this.searchKey = searchKey;
        PollManager pollManager = new PollManager();
        ErrorInfo error = new ErrorInfo();
        searchResultsRepeater.DataSource = pollManager.SearchPolls(searchKey, error);
        searchResultsRepeater.DataBind();
    }
}
